{% extends "oa/base.html" %}
{% load i18n static %}
{% block title %} 发酵罐状态 {% endblock %}
{% block this_css %}
<style>
    tr.success > td.volume-left {
        color: #D02000;
    }
    tr > th {
        text-align: center;
    }
    td.tank-info {
        height: 22.5pt;
    }
</style>
{% endblock %}
{% block content %}
    <section class="wrapper">

        <div class="col-lg-10 col-lg-offset-1">
            <section class="panel">
                <div class="text-right">
                    <a class="btn btn-success" data-toggle="modal" href="#updateState">
                        更新状态
                    </a>
                </div>
            </section>
        </div>

        <div class="modal fade modal-dialog-center " id="updateState" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog ">
                <div class="modal-content-wrap">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title">更新发酵罐状态</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-horizontal" method="post" action="{{ request.path }}"
                                  enctype="multipart/form-data">{% csrf_token %}
                                <div class="form-group">
                                    <div class="col-lg-2 control-label"><label for="equipment_id">发酵罐</label></div>
                                    <div class="col-lg-10">
                                        <select id="equipment_id" name="equipment_id" class="form-control">
                                            {% for equipment in equipments %}
                                                {% if request.GET.equipment_id|escape == equipment.pk|escape %}
                                                    <option value="{{ equipment.pk }}" selected>{{ equipment.code }}</option>
                                                {% else %}
                                                    <option value="{{ equipment.pk }}">{{ equipment.code }}</option>
                                                {% endif %}
                                            {% endfor %}
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-2 control-label"><label for="tank_state">状态</label></div>
                                    <div class="col-lg-10">
                                        <select id="tank_state" name="tank_state" class="form-control">
                                            {% for state_code, state_name in states.items %}
                                                {% if request.GET.tank_state|escape == state_code|escape %}
                                                    <option value="{{ state_code }}" selected>{{ state_name }}</option>
                                                {% else %}
                                                    <option value="{{ state_code }}">{{ state_name }}</option>
                                                {% endif %}
                                            {% endfor %}
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-lg-12 text-right">
                                        <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                                        <button type="submit" class="btn btn-success">确认</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-lg-10 col-lg-offset-1">
            <section class="panel">
                <header class="panel-heading"><h3>发酵罐状态</h3></header>
                <div class="panel-body">
                    <section id="flip-scroll">
                        <table class="table table-bordered table-striped table-condensed cf">
                            <thead>
                            <tr>
                                <th>设备编号</th>
                                <th>产品名称</th>
                                <th>生产批次</th>
                                <th>
                                    <a style="color: #0a001f" data-toggle="tooltip" title="该批次产品开始生产的日期"> 起始日期 </a>
                                </th>
                                <th>
                                    <a style="color: #0a001f" data-toggle="tooltip" title="该批次产品进入此容器的日期"> 入罐日期 </a>
                                </th>
                                <th>天数</th>
                                <th>批次容量</th>
                                <th>预估出酒量</th>
                                <th>实际出酒量</th>
                                <th>剩余可出</th>
                                <th>状态</th>
                                <th>灌装记录</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for equipment in data.equipments %}
                                {% ifequal equipment.class 'finish' %}
                                <tr class="text-center">
                                    <td class="tank-info">{{ equipment.equipment__code }}</td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info"></td>
                                    <td class="tank-info">{{ equipment.product_state }}</td>
                                    <td class="tank-info"></td>
                                </tr>
                                {% else %}
                                <tr class="text-center {{ equipment.class }}">
                                    <td class="tank-info">{{ equipment.equipment__code }}</td>
                                    <td class="tank-info text-left">{{ equipment.product_batch__product_name__name }}</td>
                                    <td class="tank-info"><a href="/page/product_batch_detail/{{ equipment.product_batch__id }}/">{{ equipment.product_batch__code }}</a></td>
                                    <td class="tank-info">{{ equipment.product_batch__start_date|date:'Y-m-d' }}</td>
                                    <td class="tank-info">{{ equipment.datetime_start|date:'Y-m-d' }}</td>
                                    <td class="tank-info">{{ equipment.delta_days }}</td>
                                    <td class="tank-info">{{ equipment.product_batch__total_volume }}</td>
                                    <td class="tank-info">{{ equipment.product_batch__est_volume }}</td>
                                    <td class="tank-info">{{ equipment.product_batch__act_volume }}</td>
                                    <td class="volume-left tank-info">{{ equipment.volume_left }}</td>
                                    <td class="tank-info">{{ equipment.product_state }}</td>
                                    <td class="text-left">
                                        <ul>
                                            {% for pack in equipment.packs %}
                                                <li>{{ pack.code }}
                                                    [{{ pack.product_package__code }}]{{ pack.product_package__name }}*{{ pack.pack_amount }}</li>
                                            {% endfor %}
                                        </ul>
                                    </td>
                                </tr>
                                {% endifequal %}
                            {% endfor %}
                            </tbody>
                        </table>
                    </section>
                </div>
            </section>
        </div>
    </section>
<script>
    $(function () { $("[data-toggle='tooltip']").tooltip(); });
</script>
{% endblock %}